package com.study.gupao.strategy;

import java.util.HashMap;

/**
 * @ClassName: StrategyAchieve
 * @Description: 策略实现核心
 * @author: Administrator
 * @Date: 2019-03-18 09:57
 */
public class StrategyAchieve {

    public static final String CAR = "qiche";
    public static final String TRAIN = "huoche";
    public static final String AIRCRAFT = "feiji";

    private HashMap<String,Strategy> strategyMap = new HashMap<>();
    public StrategyAchieve(){
        strategyMap.put(CAR,new AircraftStrategy());
        strategyMap.put(TRAIN,new CarStrategy());
        strategyMap.put(AIRCRAFT,new TrainStrategy());
    }

    public ResultBean getStrategy(String strategy){
        ResultBean result = new ResultBean();
        if (strategyMap.get(strategy) == null){
            result.setMsg("传入参数无法解析");
            result.setCode("500");
        }else {
            Strategy strategy1 = strategyMap.get(strategy);
            strategy1.strategy();
            result.setMsg("旅游策略生成");
            result.setCode("200");
            result.setData(strategy1);
        }
        return result;
    }

}
